{include file="publics/head"/}
<body class="no-skin">
{include file="publics/header"/}
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    {include file="publics/sidebar"/}
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            {include file="publics/breadcrumbs"/}

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">
                {include file="publics/set"/}

                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <div class="row">
                            <div class="cf">
                                <a class="btn btn-info" href="{:url('add')}" value="">新增</a>
                                <a class="btn btn-purple" href="{:url('setMenu')}" value="">更新菜单</a>
                            </div>
                            <div class="space-4"></div>
                            <form id="form" method="post" action="{:url('del')}">
                                <table class="table table-striped table-bordered table-hover">
                                    <thead>
                                    <tr>
                                        <th class="center">菜单名称</th>
                                        <th class="center">类型</th>
                                        <th class="center">KEY值</th>
                                        <th class="center">URL值</th>
                                        <th class="center">排序</th>
                                        <th class="center">显示</th>
                                        <th class="center">操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    {volist name="list" id="val"}
                                        <tr>

                                            <td>{$val['name']}</td>
                                            <td>{$val['type']}</td>
                                            <td>{$val['key']}</td>
                                            <td>{$val['url']}</td>
                                            <td>{$val['order']}</td>
                                            <td class="center">
                                                {if condition="$val.status eq 1"}显示
                                                    {else/}
                                                    隐藏
                                                {/if}
                                            </td>
                                            <td class="center"><a href="{:url('edit',array('id'=>$val['menu_id']))}" >修改</a>&nbsp;<a
                                                    class="del" href="javascript:;" val="{:url('del',array('ids'=>$val['menu_id']))}"
                                                    title="删除">删除</a></td>
                                        </tr>
                                        {notempty name="val.children"}
                                            {volist name="val.children" id="v"}
                                                <tr>
                                                    <td>&nbsp;&nbsp;&nbsp;&nbsp;┗━{$v['name']}</td>
                                                    <td>{$v['type']}</td>
                                                    <td>{$v['key']}</td>
                                                    <td>{$v['url']}</td>
                                                    <td>{$v['order']}</td>
                                                    <td class="center">
                                                        {if condition="$v.status eq 1"}显示
                                                            {else/}
                                                            隐藏
                                                        {/if}
                                                    </td>
                                                    <td class="center"><a href="{:url('edit',array('id'=>$v['menu_id']))}">修改</a>&nbsp;<a
                                                            class="del" href="javascript:;"
                                                            val="{:url('del',array('ids'=>$v['menu_id']))}" title="删除">删除</a></td>
                                                </tr>
                                            {/volist}
                                        {/notempty}
                                    {/volist}
                                    </tbody>
                                </table>
                            </form>
                            <div class="cf">
                                <input id="submit" class="btn btn-info" type="button" disabled value="批量删除">
                            </div>
                            {$page}
                        </div>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    {include file="publics/footer"/}

</div><!-- /.main-container -->

{include file="publics/footerjs"/}
<!-- inline scripts related to this page -->
<script type="text/javascript">
    $(function () {

        $("#submit").click(function () {
            bootbox.confirm({
                title: "系统提示",
                message: "确定要删除所选？",
                callback: function (result) {
                    if (result) {

                    }
                },
                buttons: {
                    "cancel": {"label": "取消"},
                    "confirm": {
                        "label": "确定",
                        "className": "btn-danger"
                    }
                }
            });
        });
        $(".del").click(function () {
            var url = $(this).attr('val');
            bootbox.confirm({
                title: "系统提示",
                message: "确定要删除?",
                callback: function (result) {
                    if (result) {
                        $.ajax({
                            type: "get",
                            url: url,
                            dataType: 'JSON',
                            error: function () {
                                return false;
                            },
                            success: function (data) {
                                bootbox.alert({
                                    buttons: {
                                        ok: {label: '确定',className: 'btn-danger'}
                                    },
                                    message: data.message,
                                    callback: function() {
                                        location.reload();
                                    },
                                    title: "系统提示",
                                });
                            }
                        });
                    }
                },
                buttons: {
                    "cancel": {"label": "取消"},
                    "confirm": {
                        "label": "确定",
                        "className": "btn-danger"
                    }
                }
            });
        });
    })
</script>
</body>
</html>
